package com.inossem.warehousestorage_inossem.activity.query;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.inossem.utils.listener.NoDoubleClickListener;
import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;
import com.inossem.warehousestorage_inossem.activity.query.extra.QueryExtra;
import com.inossem.warehousestorage_inossem.utils.ActivityUtils;
import com.zhy.android.percent.support.PercentRelativeLayout;

public class QueryManageActivity extends BaseActivity {

    TextView title;

    PercentRelativeLayout materielInventorySelect, batchInventorySelect,outStorageSelect;

    private boolean mFlag = false;

    @Override
    protected void onCreateImpl(Bundle savedInstanceState) {
        setContentView(R.layout.activity_query_manage);
        initView(QueryManageActivity.this);
        initData(QueryManageActivity.this);
    }

    private void initView(Activity activity) {
        title = (TextView) activity.findViewById(R.id.headerTitle);
        materielInventorySelect = (PercentRelativeLayout) activity.findViewById(R.id.materielInventorySelect);
        batchInventorySelect = (PercentRelativeLayout) activity.findViewById(R.id.batchInventorySelect);
        outStorageSelect = (PercentRelativeLayout) activity.findViewById(R.id.outStorageSelect);

    }

    private void initData(Activity activity) {
        title.setText(activity.getResources().getString(R.string.activity_query_manage_title));
        ActivityUtils.initBackAndFunction(activity, R.string.activity_query_manage_title, new NoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                finish();
            }
        });
        getExtra(activity);
        if (mFlag) {
//            Intent intent = new Intent(activity, UpFrame_ManageActivity.class);
//            startActivity(intent);
//            finish();
        } else {
            materielInventorySelect.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(QueryManageActivity.this, QueryMaterielDetailActivity.class);
                    intent.putExtra(QueryExtra.TYPE, QueryMaterielDetailActivity.SINGLE);
                    startActivity(intent);
                }
            });
            batchInventorySelect.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(QueryManageActivity.this, QueryBatchInventorySelectActivity.class);
                    startActivity(intent);
                }
            });
            outStorageSelect.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(QueryManageActivity.this, QueryOutStorageSelectActivity.class);
                    startActivity(intent);
                }
            });
        }
    }

    private void getExtra(Activity activity) {
        mFlag = activity.getIntent().getBooleanExtra(QueryExtra.FLAG, false);
    }

}
